package com.example.smart.ui.activity.home

import com.example.lib.extend.setOnDoubleClickListener
import com.example.lib.utils.ToastUtils
import com.example.lib.utils.sp.SpUtils
import com.example.lib.utils.statusbar.StatusBarUtils
import com.example.smart.R
import com.example.smart.base.ui.activity.BaseTitleBarActivity
import com.example.smart.databinding.ActivityVaccinesDetailsBinding
import com.example.smart.listener.CopyVideoListener
import com.example.smart.utils.DisplayUtils
import com.example.smart.utils.FileUtils

class VaccinesDetailsActivity : BaseTitleBarActivity<ActivityVaccinesDetailsBinding>() {
    private var flag = SpUtils.getBoolean("vaccines", false)

    override fun layoutID() = R.layout.activity_vaccines_details

    override fun initView() {
        StatusBarUtils.setStateAndNavigationBar(this@VaccinesDetailsActivity,
            statusBarColor = com.example.lib.R.color.white)
        title = getString(R.string.vaccines_title0)
        binding.Gz.setImageResource(if (flag) R.mipmap.icon_heart else R.mipmap.icon_heart_not)

        binding.GzBack.setBackgroundResource(if (flag) com.example.lib.R.drawable.round_white else R.mipmap.icon_heart_not_back)
    }

    override fun initListener() {

        binding.GzBack.setOnDoubleClickListener {
            flag = !flag
            binding.Gz.setImageResource(if (flag) R.mipmap.icon_heart else R.mipmap.icon_heart_not)
            binding.GzBack.setBackgroundResource(if (flag) com.example.lib.R.drawable.round_white else R.mipmap.icon_heart_not_back)
            SpUtils.putBoolean("vaccines", flag)
        }

        binding.Gz.setOnDoubleClickListener {
            flag = !flag
            binding.Gz.setImageResource(if (flag) R.mipmap.icon_heart else R.mipmap.icon_heart_not)
            binding.GzBack.setBackgroundResource(if (flag) com.example.lib.R.drawable.round_white else R.mipmap.icon_heart_not_back)
            SpUtils.putBoolean("vaccines", flag)
        }


        binding.LookOther.setOnDoubleClickListener {
            DisplayUtils.toVaccinesPoint(this@VaccinesDetailsActivity)
        }

        binding.Rel1.setOnDoubleClickListener {
            FileUtils.copyVideo(this@VaccinesDetailsActivity, "video1.mp4", object : CopyVideoListener {
                override fun onSuccess(path: String) {
                    DisplayUtils.toVideo(this@VaccinesDetailsActivity, path)
                }

                override fun onFail() {
                    ToastUtils.showToast("播放失败，请稍后重试！")
                }
            })
        }

        binding.Rel2.setOnDoubleClickListener {
            FileUtils.copyVideo(this@VaccinesDetailsActivity, "video1.mp4", object : CopyVideoListener {
                override fun onSuccess(path: String) {
                    DisplayUtils.toVideo(this@VaccinesDetailsActivity, path)
                }

                override fun onFail() {
                    ToastUtils.showToast("播放失败，请稍后重试！")
                }
            })
        }
    }

}